#ifndef _MATERIALVIEWWIDGET_H_
#define _MATERIALVIEWWIDGET_H_
#include <SEUi/Widget/Widget.h>
#include <SERender/Renderer/Renderer.h>
#include <SERender/Resourses/FrameBuffer.h>
#include <SERender/Entity/Camera.h>
#include <SECore/Ecs/Scene.h>
#include <SECore/Ecs/Actor.h>

namespace SEngine
{

    class EditLayer;
    class MaterialViewWidget : public Widget
    {
    public:
        MaterialViewWidget(EditLayer &);
        virtual ~MaterialViewWidget() = default;
        Camera & GetCamera() { return m_editCamera; }
        void LoadMaterial(ResRef<Material> material);
    protected:
        virtual void BeginUpdate() override;
        virtual void UpdateImpl(int delta) override;
        virtual void EndUpdate() override;
        void ShowMenuBar();

    private:
        EditLayer & m_layer;
        std::unique_ptr<Renderer> m_renderer;
        std::unique_ptr<FrameBuffer> m_fbo;
        std::unique_ptr<Texture2D> m_targetMap;
        std::shared_ptr<Scene> m_scene;
        Camera m_editCamera;
        std::weak_ptr<Actor> m_baseActor;
        std::weak_ptr<Actor> m_pointLight;
        std::weak_ptr<Actor> m_directLight;
        std::weak_ptr<Actor> m_hdrSkybox;
    };
} // namespace SEngine


#endif